
using System;

namespace MiniBotAlgorithmLibSample
{
    public partial class ApiSamples
    {

        /*
        关节角转空间坐标
       */
        public void Sample_RobotAddNRemoveNBindNSendCmd()
        {
            var id = MiniBotAlgorithmLib.AddRobot(2, new byte[] { 31, 32, 33, 34, 35 }, 5);
            var rs = MiniBotAlgorithmLib.BindRobotModuleApis(id, SetPositionCallback, SetPositionWithSpeedCallback, SetMultiPositionCallback,
             SetMultiPositionWithSpeedCallback, SetSpeedCallback, SetRunningSpeedCallback, SetTorqueEnableCallback, SetModeCallback);
            Console.WriteLine("MinibotAlgorithmNativeApi.BindRobotModuleApis Completed.\n\n");

            MiniBotAlgorithmLib.SendCmd(id, 0, 0);
            MiniBotAlgorithmLib.SendCmd(id, 1, 0);

            Console.ReadLine();
        }

        #region 硬件模块控制方法(用于执行运动学算法设置舵机参数的回调)


        public static void SetPositionCallback(byte id, double angle)
        {
            Console.WriteLine($"SetPositionCallback:{id}-{angle}");
        }

        public static void SetPositionWithSpeedCallback(byte id, double angle, int speedPercent)
        {
            Console.WriteLine($"SetPositionWithSpeedCallback:{id}-{angle}");
        }

        public static void SetMultiPositionCallback(IntPtr pids, IntPtr pangles, int count)
        {

            Console.WriteLine($"SetMultiPositionCallback:-{count}");
        }


        public static void SetMultiPositionWithSpeedCallback(IntPtr pids, IntPtr pangles, int count, int speedPercent)
        {
            Console.WriteLine($"SetMultiPositionWithSpeedCallback:{count}-{speedPercent}");
        }


        public static void SetSpeedCallback(byte id, int speedPercent)
        {
            Console.WriteLine($"SetSpeedCallback:{id}-{speedPercent}");
        }

        public static void SetRunningSpeedCallback(byte id, int speedPercent)
        {
            Console.WriteLine($"SetRunningSpeedCallback:{id}-{speedPercent}");
        }

        public static void SetTorqueEnableCallback(byte id, bool isEnable)
        {
            Console.WriteLine($"SetTorqueEnableCallback:{id}-{isEnable}");
        }

        public static void SetModeCallback(byte id, int mode)
        {
            Console.WriteLine($"SetModeCallback:{id}-{mode}");
        }

        #endregion
    }
}


